package de.game;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

public class Util {
	
	public static Bitmap getBitmapFromDrawable(Context c, int r_drawable_id){
		return BitmapFactory.decodeResource(c.getResources(),r_drawable_id);
	}
	
	public static void startViewFadeAnimation(Context c, View v){
		Animation fadeInAnimation = AnimationUtils.loadAnimation(c, R.anim.fade_amin);
		v.startAnimation(fadeInAnimation);
	}
	
	public static void stopViewFadeAnimation(View v){
		v.clearAnimation();
	}
	
	public static int randomNrBetween(int lowerBound, int upperBound){
		return lowerBound + (int) ( Math.random()*(upperBound -lowerBound) + 0.5 );
	}

	public static Bitmap getBitmapFromDrawable(Resources res, int r_drawable_id) {
		return BitmapFactory.decodeResource(res, r_drawable_id);
	}
	
}
